package com.backstage.controller;

import com.backstage.pojo.User;
import com.backstage.service.UserService;
import com.backstage.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping(value = "/admin")
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping(value = "/user_list", method = RequestMethod.GET)
    public String userlist(@RequestParam(required = false, defaultValue = "1") int page,
                         @RequestParam(required = false, defaultValue = "10") int pageSize,
                         @RequestParam(required = false, defaultValue = " ") String keyWord,
                         Model model){
        PageBean<User> pageBean = userService.selectUserList(page, pageSize, keyWord);
        model.addAttribute("list",pageBean.getList());
        model.addAttribute("pager",pageBean.getPageBeanObj());
        return "admin/user_list";
    }
}
